Quantum circuit optimization using windowed quantum arithmetic

ABSTRACT

Methods, systems and apparatus for performing windowed quantum arithmetic. In one aspect, a method for performing a product addition operation includes: determining multiple entries of a lookup table, comprising, for each index in a first set of indices, multiplying the index value by a scalar for the product addition operation; for each index in a second set of indices, determining multiple address values, comprising extracting source register values corresponding to indices between i) the index in the second set of indices, and ii) the index in the second set of indices plus the predetermined window size; and adjusting values of a target quantum register based on the determined multiple entries of the lookup table and the determined multiple address values.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a divisional of U.S. Application No, 16/833,250, filed Mar. 27, 2020, which claims priority under 35 U.S.C. 119 to Provisional Application No. 62/826,142, filed Mar. 29, 2019, which is incorporated by reference.

BACKGROUND

This specification relates to quantum computing.

Classical computers have memories made up of bits, where each bit can represent either a zero or a one. Quantum computers maintain sequences of quantum bits, called qubits, where each quantum bit can represent a zero, one or any quantum superposition of zeros and ones. Quantum computers operate by setting qubits in an initial state and controlling the qubits, e.g., according to a sequence of quantum logic gates.

SUMMARY

This specification describes techniques for accelerating quantum computations using windowed quantum arithmetic.

In general, one innovative aspect of the subject matter described in this specification can be implemented in a method for performing a product addition operation on a target quantum register of qubits and a source quantum register of qubits, the method comprising: determining multiple entries of a lookup table, comprising, for each index in a first set of indices, wherein the first set of indices comprises index values between zero and a maximum index value that is a function of a predetermined window size, multiplying the index value by a scalar for the product addition operation; for each index in a second set of indices, wherein the second set of indices comprises index values between zero and a maximum index value that is a function of the source quantum register, wherein the index values are stepped by the predetermined window size: determining multiple address values, comprising extracting source register values corresponding to indices between i) the index in the second set of indices, and ii) the index in the second set of indices plus the predetermined window size; and adjusting values of the target quantum register based on the determined multiple entries of the lookup table and the determined multiple address values.

Other implementations of these aspects includes corresponding computer systems, apparatus, and computer programs recorded on one or more computer storage devices, each configured to perform the actions of the methods. A system of one or more classical and/or quantum computers can be configured to perform particular operations or actions by virtue of having software, firmware, hardware, or a combination thereof installed on the system that in operation causes or cause the system to perform the actions. One or more computer programs can be configured to perform particular operations or actions by virtue of including instructions that, when executed by data processing apparatus, cause the apparatus to perform the actions.

The foregoing and other implementations can each optionally include one or more of the following features, alone or in combination. In some implementations the maximum index value that is a function of the predetermined window size is equal to 2 to the power of the predetermined window size.

In some implementations the maximum index value that is a function of the source quantum register is equal to the length of the source register.

In some implementations the predetermined window size comprises In n, where n represents a number of logical qubits in the target quantum register.

In some implementations adjusting values of the target quantum register based on the determined multiple entries of the lookup table and the determined multiple address values comprises adding the determined multiple entries into the target quantum register.

In some implementations the product addition operation performs x+= ky, where x represents a variable storing a first value in the target quantum register, y represents a corresponding variable storing a second value in the source quantum register, k represents a classical constant scalar value for the product addition operation.

In some implementations the target quantum register comprises a fixed width 2 s complement register.

In some implementations the first value comprises a classical integer or a superposition of classical integers.

In some implementations the second value comprises a classical integer or a superposition of classical integers.

In general, another innovative aspect of the subject matter described in this specification can be implemented in a method for performing a modular product addition operation using a target quantum register of qubits and a source quantum register of qubits, the method comprising: for each index in a first set of indices, wherein the first set of indices comprises index values between zero and a maximum index value that is a function of the source quantum register, wherein the index values are stepped by a predetermined window size: determining multiple address values, comprising extracting source register values corresponding to indices between i) the index in the first set of indices, and ii) the index in the first set of indices plus the predetermined window size; determining multiple corresponding table entries, comprising, for each index in a second set of indices, wherein the second set of indices comprises index values between zero and a maximum table index that is a function of the predetermined window size: determining a table entry comprising a product of i) a scalar in the product addition operation, ii) 2 to the power of the index in the first set of indices, and iii) the index in the second set of indices, and applying a modulus operation to the determined table entry; and adjusting values of the target quantum register based on the determined multiple table entries and the determined multiple address values.

Other implementations of these aspects includes corresponding computer systems, apparatus, and computer programs recorded on one or more computer storage devices, each configured to perform the actions of the methods. A system of one or more classical and/or quantum computers can be configured to perform particular operations or actions by virtue of having software, firmware, hardware, or a combination thereof installed on the system that in operation causes or cause the system to perform the actions. One or more computer programs can be configured to perform particular operations or actions by virtue of including instructions that, when executed by data processing apparatus, cause the apparatus to perform the actions.

The foregoing and other implementations can each optionally include one or more of the following features, alone or in combination. In some implementations the maximum index value that is a function of the source quantum register is equal to the length of the source quantum register.

In some implementations the maximum table index that is a function of the predetermined window size is equal to 2 to the power of the predetermined window size.

In some implementations the modular product addition operation performs x+= ky (mod N), where x represents a variable storing a first value in the target quantum register, y represents a corresponding variable storing a second value in the source quantum register, k represents a classical constant scalar value for the modular product addition operation, and N represent a classical constant modulo for the modular product addition operation.

In some implementations values of x, y and k are positive and less than N.

In some implementations the first value comprises a classical integer or a superposition of classical integers.

In some implementations the second value comprises a classical integer or a superposition of classical integers.

In some implementations the predetermined window size comprises In n, where n represents a number of logical qubits in the target quantum register.

In some implementations adjusting values of the target quantum register based on the determined multiple table entries and the determined multiple address values comprises adding the determined multiple table entries into the target quantum register.

In some implementations the method further comprises performing a series of modular product addition operations to perform a modular multiplication operation.

In general, another innovative aspect of the subject matter described in this specification can be implemented in a method for multiplying values of a target quantum register of qubits by an odd integer, the method comprising: determining multiple lookup table entries, comprising, for each index in a first set of indices, wherein the first set of indices comprises index values between zero and a maximum table index that is a function of a predetermined window size: determining a product of the index in the first set of indices and the odd integer; for each index in a second set of indices, wherein the second set of indices comprises index values from a maximum index value that is a function of the target quantum register to zero, wherein the index values are stepped by a predetermined window size: extracting multiple values of the target quantum register between the index in the second set of indices to the index in the second set of indices plus the predetermined window size; and adjusting multiple values of the target quantum register based on the determined multiple lookup table entries and the extracted multiple values of the target quantum register, wherein the multiple values of the target quantum register comprise values between the index in the second set of indices plus the predetermined window size and an end of the target quantum register.

Other implementations of these aspects includes corresponding computer systems, apparatus, and computer programs recorded on one or more computer storage devices, each configured to perform the actions of the methods. A system of one or more classical and/or quantum computers can be configured to perform particular operations or actions by virtue of having software, firmware, hardware, or a combination thereof installed on the system that in operation causes or cause the system to perform the actions. One or more computer programs can be configured to perform particular operations or actions by virtue of including instructions that, when executed by data processing apparatus, cause the apparatus to perform the actions.

The foregoing and other implementations can each optionally include one or more of the following features, alone or in combination. In some implementations the maximum table index that is a function of the predetermined window size is equal to 2 to the power of the predetermined window size.

In some implementations the maximum index value that is a function of the target quantum register is equal to the length of the target quantum register.

In some implementations multiplying values of a target quantum register of qubits by an odd integer comprises performing x *= k, where x represents a variable storing a first value in the target quantum register and k represents the odd integer.

In some implementations the first value comprises a classical integer or a superposition of classical integers.

In some implementations the predetermined window size comprises ln n, where n represents a number of logical qubits in the target quantum register.

In some implementations adjusting multiple values of the target quantum register based on the determined multiple lookup table entries and the extracted multiple values of the target quantum register comprises adding the determined multiple lookup table entries into the target quantum register.

In general, another innovative aspect of the subject matter described in this specification can be implemented in a method for method for performing a modular exponentiation operation using a target quantum register of qubits and a source quantum register of qubits, the method comprising: for each index in a first set of indices, determining a first plurality of address values, comprising extracting multiple source register values; for each index in a second set of indices, determining a second plurality of address values, comprising extracting multiple target register values; for each index in a third set of indices and for each index in a fourth set of indices, determining a table entry by multiplying i) the index in the third set of indices, ii) the index in the fourth set of indices, and iii) 2 to the power of the index in the second set of indices, and applying a modulus operation; adjusting a modular addition register using table entries corresponding to the first plurality of address values and the second plurality of address values; for each index in a fifth set of indices, determining a third plurality of address values, comprising extracting multiple values of the adjusted modular addition register; for each index in a sixth set of indices, for each index in a seventh set of indices, determining a table entry by multiplying i) the index in the sixth set of indices, ii) the index in the seventh set of indices, and iii) 2 to the power of the index in the fifth set of indices, and applying a modulus operation; and adjusting the target quantum register using table entries corresponding to the first plurality of address values and the third plurality of address values.

Other implementations of these aspects includes corresponding computer systems, apparatus, and computer programs recorded on one or more computer storage devices, each configured to perform the actions of the methods. A system of one or more classical and/or quantum computers can be configured to perform particular operations or actions by virtue of having software, firmware, hardware, or a combination thereof installed on the system that in operation causes or cause the system to perform the actions. One or more computer programs can be configured to perform particular operations or actions by virtue of including instructions that, when executed by data processing apparatus, cause the apparatus to perform the actions.

The foregoing and other implementations can each optionally include one or more of the following features, alone or in combination. In some implementations the first set of indices comprises index values between zero and a first maximum index value that is a function of the source quantum register, wherein the index values are stepped by a first predetermined window size.

In some implementations the set of indices comprises index values between zero and a second maximum index value that is a function of the target register, wherein the index values are stepped by a second predetermined window size.

In some implementations the third set of indices comprises index values between 1 and a third maximum value that is based on the first predetermined window size.

In some implementations the fourth set of indices comprises index values between 0 and a fourth maximum value that is a function of the target quantum register and the second predetermined window size.

In some implementations the fifth set of indices comprises index values between zero and a fifth maximum index value that is a function of the target register, wherein the index values are stepped by the second predetermined window size.

In some implementations the sixth set of indices comprises index values between 1 and a sixth value that is based on the second predetermined window size.

In some implementations the seventh set of indices comprises index values between 0 and a seventh maximum value that is a function of the modular addition register and the second predetermined window size.

In some implementations determining the first plurality of address values comprises extracting source register values corresponding to indices between i) the index in the first set of indices, and ii) the index in the first set of indices plus the first predetermined window size.

In some implementations determining the second plurality of address values comprises extracting target register values corresponding to indices between i) the index in the second set of indices, and ii) the index in the second set of indices plus the second predetermined window size.

In some implementations determining the third plurality of address values comprises extracting values of the adjusted modular addition register corresponding to indices between i) the index in the fifth set of indices, and ii) the index in the fifth set of indices plus the second predetermined window size.

In some implementations the first maximum index value that is a function of the source quantum register is equal to the length of the source quantum register.

In some implementations the second maximum index value that is a function of the target register is equal to the length of the target quantum register.

In some implementations the third maximum value that is based on the first predetermined window size comprises k^(2i+w 1) where k represents a scalar for the modular exponentiation operation, i represents the index in the first set of indices, and w₁ represents the first predetermined window size.

In some implementations the fourth maximum value that is a function of the target quantum register and the second predetermined window size comprises 2 to the power of the second window size.

In some implementations the fifth maximum index value that is a function of the target register is equal to the length of the target quantum register.

In some implementations the seventh maximum value that is a function of the target quantum register and the second predetermined window size comprises 2 to the power of the second window size.

In some implementations the modular exponentiation operation performs x ∗= k^(e) (mod N), where x represents a variable storing a first value in the target quantum register, e represents a corresponding variable storing a second value in the source quantum register, k represents a classical constant scalar value for the modular exponentiation operation, and N represent a classical constant modulo for the modular exponentiation operation.

In some implementations the first value comprises a classical integer or a superposition of classical integers.

In some implementations the second value comprises a classical integer or a superposition of classical integers.

In some implementations the first predetermined window size and the second window size are equal.

In some implementations the first predetermined window size and second predetermined window size are equal to ln n /2, where n represents a number of logical qubits in the target quantum register.

The subject matter described in this specification can be implemented in particular ways so as to realize one or more of the following advantages.

A system implementing the presently described windowing techniques can perform quantum arithmetic tasks, e.g., product additions, multiplications and exponentiations, with lower Toffoli complexity and increased computational speed.

The presently described windowing techniques can be applied in any quantum computation that involves arithmetic operations. Because of the above described increased computational speed and reduced Toffoli count, quantum computations implementing the presently described techniques can therefore also achieve increased computational speed and a reduction in costs/computational resources.

The details of one or more implementations of the subject matter of this specification are set forth in the accompanying drawings and the description below. Other features, aspects, and advantages of the subject matter will become apparent from the description, the drawings, and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows an example quantum circuit for performing a table lookup.

FIG. 2 shows an example quantum computation system.

FIG. 3 is a flow diagram of an example process for performing a product addition operation on a target quantum register of qubits and a source quantum register of qubits.

FIG. 4 shows a snippet of executable python 3 code for performing a product addition operation on a target quantum register of qubits and a source quantum register of qubits.

FIG. 5 is a flow diagram of an example process for multiplying values of a target quantum register of qubits by an odd integer.

FIG. 6 shows a snippet of executable python 3 code for multiplying values of a target quantum register of qubits by an odd integer.

FIG. 7 is a flow diagram of an example process for performing a modular product addition operation using a target quantum register of qubits and a source quantum register of qubits.

FIG. 8 shows a snippet of executable python 3 code for performing a modular product addition operation.

FIG. 9 is a flow diagram of an example process for performing a modular exponentiation operation using a target quantum register of qubits and a source quantum register of qubits.

FIG. 10 shows a snippet of executable python 3 code for performing a modular exponentiation operation.

Like reference numbers and designations in the various drawings indicate like elements.

DETAILED DESCRIPTION Overview

In classical computing, operation counts can be reduced by merging operations together using lookup tables. For example, fast software implementations of cyclic redundancy check parity check codes process multiple bits at a time using precomputed tables. These techniques are known as “windowing.”

This specification describes windowing in quantum computing. In particular, techniques for reducing operation counts in quantum computing by merging multiple controlled operations into a single operation acting on a value produced by a QROM (quantum read only memory) lookup (referred to herein as a “table lookup”) are described.

A table lookup is an operation that retrieves data from a classical table addressed by a quantum register. It performs the operation

∑_(j = 0)^(L − 1)|j⟩ |0⟩ ↦ ∑_(j = 0)^(L − 1) |j⟩ |T_(j)⟩

where T represents a classically precomputed table with L entries. FIG. 1 is a quantum circuit diagram of an example quantum circuit 100 for performing a table lookup with a Toffoli count of L - 1 (independent of the number of bits in each entry.) In FIG. 1 , the perpendicular lines merging from and merging into other lines to form corners, e.g., merging lines 104, are AND computations and uncomputations, respectively, and are equivalent to Toffoli gates. If the control qubit 102 is set and the address register 106 contains the binary value a, the example quantum circuit 100 xors the a-th bit string from a precomputed lookup table T into W output qubits. In the example quantum circuit 100, L = 23 and W = 6. The question marks beside the CNOT targets indicate that the target should be omitted or included depending on a corresponding bit in T. Using known techniques (e.g., techniques different to those described in this specification), it is possible to compute a table lookup in O(WL/k + k) Toffolis, where W represents the output size of the lookup and k represents a freely chosen parameter.

Example Hardware

FIG. 2 depicts an example quantum computation system 200. The system 200 is an example of a system implemented as quantum and classical computer programs on one or more quantum computing devices and classical computers in one or more locations, in which the systems, components, and techniques described below can be implemented.

The system 200 includes a quantum computing device 202 in data communication with one or more classical processors 204. For convenience, the quantum computing device 202 and classical processors 204 are illustrated as separate entities, however in some implementations the classical processors 204 may be included in the quantum computing device 202.

The quantum computing device 202 includes components for performing quantum computation. For example, the quantum computing device 202 includes quantum circuitry 206 and control devices 208.

The quantum circuitry 206 includes components for performing quantum computations, e.g., components for implementing the various quantum circuits and operations described in this specification. For example, the quantum circuitry may include a quantum system that includes one or more multi-level quantum subsystems, e.g., qubits 214. The qubits 214 are physical qubits that may be used to perform algorithmic operations or quantum computations. The specific realization of the one or more qubits and their interactions may depend on a variety of factors including the type of quantum computations that the quantum computing device 202 is performing. For example, the qubits may include qubits that are realized via atomic, molecular or solid-state quantum systems. In other examples the qubits may include, but are not limited to, superconducting qubits, e.g., Gmon or Xmon qubits, or semiconducting qubits. Further examples of realizations of multi-level quantum subsystems include fluxmon qubits, silicon quantum dots or phosphorus impurity qubits. In some cases the quantum circuitry may further include one or more resonators attached to one or more superconducting qubits. In other cases ion traps, photonic devices or superconducting cavities (with which states may be prepared without requiring qubits) may be used.

In this specification, the term “quantum circuit” is used to refer to a sequence of quantum logic operations that can be applied to a qubit register to perform a respective computation. Quantum circuits comprising different quantum logic operations, e.g., single qubit gates, multi-qubit gates, etc., may be constructed using the quantum circuitry 206. Constructed quantum circuits can be operated/implemented using the control devices 208.

The type of control devices 208 included in the quantum system depend on the type of qubits included in the quantum computing device. For example, in some cases the multiple qubits can be frequency tunable. That is, each qubit may have associated operating frequencies that can be adjusted using one or more control devices. Example operating frequencies include qubit idling frequencies, qubit interaction frequencies, and qubit readout frequencies. Different frequencies correspond to different operations that the qubit can perform. For example, setting the operating frequency to a corresponding idling frequency may put the qubit into a state where it does not strongly interact with other qubits, and where it may be used to perform single-qubit operations/gates. In these examples the control devices 208 may include devices that control the frequencies of qubits included in the quantum circuitry 206, an excitation pulse generator and control lines that couple the qubits to the excitation pulse generator. The control devices may then cause the frequency of each qubit to be adjusted towards or away from a quantum gate frequency of an excitation pulse on a corresponding control driveline.

The control devices 208 may further include measurement devices, e.g., readout resonators. Measurement results obtained via measurement devices may be provided to the classical processors 204 for processing and analyzing. Measurement devices perform physical measurements on properties of the qubits, either directly or indirectly, from which the state(s) of the qubits can be inferred.

Programming the Hardware: Example Process for Performing Product Addition Operations

FIG. 3 is a flow diagram of an example process 300 for performing a product addition operation on a target quantum register of qubits and a source quantum register of qubits. For convenience, the process 300 will be described as being performed by a system of one or more classical and quantum computing devices located in one or more locations. For example, a quantum computation system, e.g., the system 200 of FIG. 2 , appropriately programmed in accordance with this specification, can perform the process 300.

The product addition operation performed by example process 300 can be given by x = x + ky (or equivalently x+= ky), where x represents a variable storing a first value in the target quantum register, y represents a corresponding variable storing a second value in the source quantum register, and k represents a (classical) constant scalar value for the product addition operation. The first value and second value are quantum integers. In this specification, a quantum integer refers to a classical integer or a superposition of classical integers stored by a quantum register, e.g., as a sequence of qubits using 2 s complement little endian format.

The system determines multiple entries of a lookup table (step 302). For each index in a first set of indices, where the first set of indices includes index values between zero and a maximum index value that is a function of a predetermined window size, the system multiplies the index value by a scalar for the product addition operation. The maximum index value that is a function of the predetermined window size can be equal to 2 to the power of the predetermined window size.

In some implementations the system can determine the entries of the lookup table using classical computation, e.g., classically performed multiplications. The lookup table defined by the determined entries can then be stored in classical memory of the system.

For each index in a second set of indices, the system determines multiple address values (step 304) and adjusts values of the target quantum register based on the determined multiple entries of the lookup table and the determined multiple address values (step 306). The second set of indices includes index values between zero and a maximum index value that is a function of the source quantum register and where the index values are stepped by the predetermined window size. The maximum index value that is a function of the source quantum register can be equal to the length of the source quantum register.

To determine the multiple address values, the system extracts source quantum register values corresponding to indices between i) the index in the second set of indices, and ii) the index in the second set of indices plus the predetermined window size. The system sets the multiple address values equal to respective extracted source quantum register values. Extracting the source quantum register values is a quantum computation performed by quantum computing devices based on quantum unitary operations/quantum gates (excluding measurements).

To adjust values of the target quantum register based on the determined multiple entries of the lookup table and the determined multiple address values, the system identifies table entries (determined at step 302) that correspond to the address values (determined at step 304). In some implementations the system may store the identified table entries in a temporary quantum register. The system uses the identified table entries to adjust a subset of entries of the target quantum register. The subset of entries correspond to entries including and after the current index from the second set of indices. To adjust the subset of entries of the target quantum register, the system adds the identified table entries into the target quantum register. For example, the system can perform a quantum addition computation using quantum computing devices, e.g., by applying a quantum addition circuit to the target quantum register and the temporary quantum register. The quantum addition circuit may include a sequence of quantum logic gates that implement an addition operation.

The windowed implementation of product addition described by example process 300 has an asymptotic Toffoli count of

$O\left( {\frac{n}{w}\left( {n + 2^{w}} \right)} \right)$

where w represents the predetermined window size. In some implementations the predetermined window size can equal ln n, where n represents a number of logical qubits in the target quantum register. In these implementations the table lookup is as expensive as the addition, achieves a Toffoli count of O(n²/ lg n).

FIG. 4 shows a snippet 400 of executable python 3 code for performing a product addition operation on a target quantum register of qubits and a source quantum register of qubits. In the code snippets described in this specification, quantum operations are specified in the same way as classical operations. The code interpreter must then decompose high level quantum arithmetic into corresponding low level quantum operations. For example, when a, b are variables holding quantum integers, the statement a+= b applies a quantum addition circuit to a and b. If b is a classical integer, then b is treated as a temporary expression (an rvalue) that must be loaded into a quantum register so that a quantum addition circuit using the classical integer can be applied. There are other kinds of rvalues that can be temporarily loaded into a register in order to add them into a target. For example, indexing a lookup table with a quantum integer produces a lookup rvalue and so the statement a += T[b] results in the following three actions: compute a table lookup with classical data T and quantum address b into a temporary register, then add the temporary register into a, then uncompute the table lookup.

Section 402 of the snippet 400 defines the product addition operation “plus_equal_product”, where “target” represents the target quantum register, “Quint” represents a quantum integer, “k” represents the constant scalar value for the product addition operation, “int” represents a classical integer, “y” represents the source quantum register, “window” represents the predetermined window size.

Section 404 of the snippet 400 corresponds to step 302 of example process 300. For each index i in a first set of indices that ranges from zero to 2^(window), a respective table entry value i ∗ k is computed. Section 406 of the snippet 400 corresponds to step 304 of example process 300. For each index i in a second set of indices that ranges from 0 to the length of the source quantum register len(y) stepped by the window size, values within a corresponding segment of the target register are adjusted based on values in a corresponding set of the computed table entries, where the size of the set equals the predetermined window size.

Programming the Hardware: Example Process for Performing Multiplication Operations

FIG. 5 is a flow diagram of an example process 500 for multiplying values of a target quantum register of qubits by an odd integer. For convenience, the process 500 will be described as being performed by a system of one or more classical and quantum computing devices located in one or more locations. For example, a quantum computation system, e.g., the system 200 of FIG. 2 , appropriately programmed in accordance with this specification, can perform the process 500.

The multiplication operation performed by example process 500 can be given by x ∗= k, where x represents a variable storing a first value in the target quantum register and k represents an odd integer. The first value is a quantum integer, as defined above with reference to example process 300.

The system determines multiple entries of a lookup table (step 502). For each index in a first set of indices, where the first set of indices includes index values between zero and a maximum table index that is a function of a predetermined window size, the system determines a product of the index in the first set of indices and the odd integer. The maximum table index that is a function of the predetermined window size can equal to 2 to the power of the predetermined window size.

In some implementations the system can determine the entries of the lookup table using classical computation, e.g., classically performed multiplications. The lookup table defined by the determined entries can then be stored in classical memory of the system.

For each index in a second set of indices, the system extracts multiple values of the target quantum register (step 504) and adjusts multiple values of the target quantum register based on the determined multiple lookup table entries and the extracted multiple values of the target quantum register (step 506). The second set of indices includes index values from a maximum index value that is a function of the target quantum register to zero, where the index values are stepped by a predetermined window size. The maximum index value that is a function of the target quantum register can equal to the length of the target quantum register.

To extract multiple values of the target quantum register, the system extracts values between the index in the second set of indices to the index in the second set of indices plus the predetermined window size. Extracting the target quantum register values is a quantum computation performed by quantum computing devices.

To adjust values of the target quantum register based on the determined multiple entries of the lookup table and the extracted multiple address values, the system identifies table entries (determined at step 502) that correspond to the address values (determined at step 504). In some implementations the system may store the identified table entries in a temporary quantum register. The system uses the identified table entries to adjust a subset of entries of the target quantum register. The subset of entries correspond to entries including and after the current index from the second set of indices plus the window size. To adjust the subset of entries of the target quantum register, the system adds the identified table entries into the target quantum register. For example, the system can perform a quantum addition computation using quantum computing devices, e.g., by applying a quantum addition circuit to the target quantum register and the temporary quantum register. The quantum addition circuit may include a sequence of quantum logic gates that implement an addition operation.

The windowed multiplication described by example process 500 has Toffoli count of

$O\left( {\frac{n}{w}\mspace{6mu} \cdot \mspace{6mu}\left( {n\mspace{6mu} + \mspace{6mu} 2^{w}\mspace{6mu} + \, w^{2}} \right)} \right)$

where w represents the predetermined window size. In some implementations the predetermined window size can equal ln n, where n represents a number of logical qubits in the target quantum register. In these implementations the Toffoli count is O(n²/lgn).

FIG. 6 shows a snippet 600 of executable python 3 code for multiplying values of a target quantum register of qubits by an odd integer.

Section 602 of the snippet 600 defines the multiplication operation. As in snippet 400, “target” represents the target quantum register, “Quint” represents a quantum integer, “k” represents a constant scalar value for the multiplication operation, “int” represents a classical integer, and “window” represents the predetermined window size.

Section 604 of the snippet 600 defines an optional routine for normalizing the scalar value k. Section 606 of the snippet 600 corresponds to step 502 of example process 500. Section 608 of the snippet 600 corresponds to steps 504 and 506 of example process 500. Section 610 of the snippet 600 defines a routine for fixing up the window, e.g., to complete the multiplication operation for all target register entries previously not operated on during section 608.

Programming the Hardware: Example Process for Performing Modular Product Additions

FIG. 7 is a flow diagram of an example process 700 for performing a modular product addition operation using a target quantum register of qubits and a source quantum register of qubits. For convenience, the process 700 will be described as being performed by a system of one or more classical and quantum computing devices located in one or more locations. For example, a quantum computation system, e.g., the system 200 of FIG. 2 , appropriately programmed in accordance with this specification, can perform the process 700.

The modular product addition operation performed by example process 700 can be given by x+= ky (mod N), where x represents a variable storing a first value in the target quantum register, y represents a corresponding variable storing a second value in the source quantum register, k represents a classical constant scalar value for the modular product addition operation, and N represent a classical constant modulo for the modular product addition operation. In some implementations values of x, y and k are positive and less than N. As described above with reference to FIG. 3 , the first value and the second value can be quantum integers.

For each index in a first set of indices, the system determines multiple address values (step 702) and determines multiple table entries (step 704). The first set of indices includes index values between zero and a maximum index value that is a function of the source quantum register, where the index values are stepped by a predetermined window size. The maximum index value that is a function of the source quantum register can be equal to the length of the source quantum register.

To determine the multiple address values, the system extracts source quantum register values corresponding to indices between i) the index in the first set of indices, and ii) the index in the first set of indices plus the predetermined window size. The system sets the multiple address values as equal to respective extracted source quantum register values. Extracting the source quantum register values is a quantum computation performed by quantum computing devices.

To determine the multiple table entries, the system determines, for each index in a second set of indices, a table entry given by a product of i) a scalar in the product addition operation, ii) 2 to the power of the index in the first set of indices, and iii) the index in the second set of indices, then applies a modulus operation corresponding to the modular product addition operation to the determined table entry. The second set of indices includes index values between zero and a maximum table index that is a function of the predetermined window size, e.g., 2 to the power of the predetermined window size. In some implementations the system can determine the entries of the table using classical computation, e.g., classically performed multiplications. The table defined by the determined entries can then be stored in classical memory of the system.

The system then adjusts values of the target quantum register based on the determined multiple table entries and the determined multiple address values (step 706), e.g., using table entries corresponding to the determined address values. In some implementations the system may store the table entries corresponding to the determined address values in a temporary quantum register. The system uses the table entries to adjust entries of the target quantum register. To adjust the entries of the target quantum register, the system adds the determined table entries into the target quantum register. For example, the system can perform a quantum addition computation using quantum computing devices, e.g., by applying a quantum addition circuit to the target quantum register and the temporary quantum register. The quantum addition circuit may include a sequence of quantum logic gates that implement an addition operation.

The windowed modular product addition described by example process 700 has Toffoli count of

$O\left( {\frac{n}{w}\left( {n + 2^{w}} \right)} \right)$

where w represents the predetermined window size. In some implementations the predetermined window size can equal ln n, where n represents a number of logical qubits in the target quantum register. In these implementations the Toffoli count is O(n²/ ln n).

A series of modular product additions can be performed to perform a modular multiplication operation x ∗= k (mod N) where k has a multiplicative inverse modulo N and both are classical constants.

FIG. 8 shows a snippet 800 of executable python 3 code for performing a modular product addition operation. Section 802 of the snippet 800 defines the modular product addition operation “plus_equal_product_mod”, where “target” represents the target quantum register, “Quint” represents a quantum integer, “QuintMod” represents a quantum integer associated with a modulus, “k” represents the constant scalar value for the modular product addition operation, “int” represents a classical integer, “y” represents the source quantum register, and “window” represents the predetermined window size.

Section 804 of the snippet 800 corresponds to step 702 of example process 700. Section 806 of snippet 800 corresponds to step 704 of example process 700. Section 808 of snippet 800 corresponds to step 706 of example process 700.

Programming the Hardware: Example Process for Performing Modular Product Additions

FIG. 9 is a flow diagram of an example process 900 for performing a modular exponentiation operation using a target quantum register of qubits and a source quantum register of qubits. For convenience, the process 900 will be described as being performed by a system of one or more classical and quantum computing devices located in one or more locations. For example, a quantum computation system, e.g., the system 200 of FIG. 2 , appropriately programmed in accordance with this specification, can perform the process 900.

The modular exponentiation operation performed by example process 900 can be given by x ∗= k^(e) (mod N), where x represents a variable storing a first value in the target quantum register, e represents a corresponding variable storing a second value in the source quantum register, k represents a classical constant scalar value for the modular exponentiation operation, and N represent a classical constant modulo for the modular exponentiation operation. The first value can be a classical integer or a superposition of classical integers. The second value can be a classical integer or a superposition of classical integers.

For each index in a first set of indices, where the first set of indices includes index values between zero and a first maximum index value that is a function of the source quantum register, e.g., equal to the length of the source quantum register, and where the index values are stepped by a first predetermined window size, the system performs steps 902-908.

The system determines a first number of address values by extracting source quantum register values corresponding to indices between i) the index in the first set of indices, and ii) the index in the first set of indices plus the first predetermined window size (step 902). Extracting the source quantum register values is a quantum computation performed by quantum computing devices.

For each index in a second set of indices, where the second set of indices includes index values between zero and a second maximum index value that is a function of the target register, e.g., equal to the length of the target quantum register, and where the index values are stepped by a second predetermined window size, the system performs steps 904, 906, 908.

The system determines a second number of address values by extracting target register values corresponding to indices between i) the index in the second set of indices, and ii) the index in the second set of indices plus the second predetermined window size (step 904). Extracting the target quantum register values is a quantum computation performed by quantum computing devices.

For each index in a third set of indices, where the third set of indices includes index values between 1 and a third maximum value that is based on the first predetermined window size, e.g., k^(2i+w 1) where k represents a scalar for the modular exponentiation operation, i represents the index in the first set of indices, and w₁ represents the first predetermined window size, the system performs step 906.

For each index in a fourth set of indices, where the fourth set of indices includes index values between 0 and a fourth maximum value that is a function of the target quantum register and the second predetermined window size, e.g., 2 to the power of the second window size, the system determines a table entry by multiplying i) the index in the third set of indices, ii) the index in the fourth set of indices, and iii) 2 to the power of the index in the second set of indices, and applying a modulus operation (step 906). In some implementations the system can determine entries of the table using classical computation, e.g., classically performed multiplications. The table defined by the determined entries can then be stored in classical memory of the system.

The system adjusts a modular addition register of qubits using table entries corresponding to the first number of address values and the second number of address values (step 908). For example, the system can perform a quantum addition computation using quantum computing devices, e.g., by applying a quantum addition circuit to the modular addition register and a temporary quantum register storing table entries corresponding to the first number of address values and the second number of address values. The quantum addition circuit may include a sequence of quantum logic gates that implement an addition operation.

For each index in a fifth set of indices, where the fifth set of indices includes index values between zero and a fifth maximum index value that is a function of the target register, e.g., equal to the length of the target quantum register, and where the index values are stepped by the second predetermined window size, the system performs steps 910-914.

The system determines a third number of address values by extracting values of the adjusted modular addition register corresponding to indices between i) the index in the fifth set of indices, and ii) the index in the fifth set of indices plus the second predetermined window size (step 910). Extracting the values is a quantum computation performed by quantum computing devices.

For each index in a sixth set of indices, where the sixth set of indices includes index values between 1 and a sixth value that is based on the second predetermined window size, the system performs step 912.

For each index in a seventh set of indices, where the seventh set of indices includes index values between 0 and a seventh maximum value that is a function of the modular addition register and the second predetermined window size, e.g., equal to 2 to the power of the second window size, the system determines a table entry by multiplying i) the index in the sixth set of indices, ii) the index in the seventh set of indices, and iii) 2 to the power of the index in the fifth set of indices, and applying a modulus operation (step 912).

The system adjusts (e.g., through subtraction) the target quantum register using table entries corresponding to the first number of address values and the third number of address values (step 914).

The windowed modular exponentiation described by example process 900 has Toffoli count of

$O\left( {\frac{n_{e}n}{w_{e}w_{m}}\left( {n\mspace{6mu} + \mspace{6mu} 2^{w_{e} + w_{m}}} \right)} \right)$

where n_(e) represents the number of exponent qubits, n represents the register size, w_(e) represents the exponent windowing size (the first predetermined window size), and w_(m) represents the multiplication windowing (the second predetermined window size). In some implementations the first predetermined window size and the second window size can be equal. For example, the first predetermined window size and second predetermined window size can both be equal to ln n /2, where n represents a number of logical qubits in the target quantum register. These window sizes produce a Toffoli count of

$O\left( \frac{n_{e}n^{2}}{\text{lg}^{2}\mspace{6mu} n} \right)$

which saves two log factors over known, alternative algorithms.

FIG. 10 shows a snippet 1000 of executable python 3 code for performing a modular exponentiation operation. Section 1002 of the snippet 1000 defines the modular exponentiation operation “times_equal_exp_mod”, where “target” represents the target quantum register, “Quint” represents a quantum integer, “QuintMod” represents a quantum integer associated with a modulus, “k” represents the constant scalar value for the modular exponentiation operation, “int” represents a classical integer, “e” represents the source quantum register, “e_window” represents the first predetermined window size and “m_window” represents the second predetermined window size.

Section 1004 of the snippet 1000 corresponds to the first set of indices. Section 1006 corresponds to step 902 of example process 900. Section 1008 corresponds to the second set of indices. Section 1010 corresponds to step 904 of example process 900. Section 1012 corresponds to the third, fourth sets of indices and step 906 of example process 900. Section 1014 corresponds to step 908 of example process 900.

Section 1016 of the snippet 1000 corresponds to the fifth set of indices. Section 1018 corresponds to step 910 of example process 900. Section 1020 corresponds to the sixth, seventh set of indices and step 912 of example process 900. Section 1022 corresponds to step 914 of example process 900. Sections 1024 and 1026 are optional routines for a relabeling swap and Xoring a swap result into a correct register.

Implementations of the digital and/or quantum subject matter and the digital functional operations and quantum operations described in this specification and appendix can be implemented in digital electronic circuitry, suitable quantum circuitry or, more generally, quantum computational systems, in tangibly-embodied digital and/or quantum computer software or firmware, in digital and/or quantum computer hardware, including the structures disclosed in this specification and their structural equivalents, or in combinations of one or more of them. The term “quantum computational systems” may include, but is not limited to, quantum computers, quantum information processing systems, quantum cryptography systems, or quantum simulators. Quantum computation systems in general and quantum computers specifically may be realized or based on different quantum computational models and architectures. For example, the quantum computation system may be based on or described by models such as the quantum circuit model, one-way quantum computation, adiabatic quantum computation, holonomic quantum computation, analog quantum computation, digital quantum computation, or topological quantum computation.

Implementations of the digital and/or quantum subject matter described in this specification can be implemented as one or more digital and/or quantum computer programs, i.e., one or more modules of digital and/or quantum computer program instructions encoded on a tangible non-transitory storage medium for execution by, or to control the operation of, data processing apparatus. The digital and/or quantum computer storage medium can be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, one or more qubits, or a combination of one or more of them. Alternatively or in addition, the program instructions can be encoded on an artificially-generated propagated signal that is capable of encoding digital and/or quantum information, e.g., a machine-generated electrical, optical, or electromagnetic signal, that is generated to encode digital and/or quantum information for transmission to suitable receiver apparatus for execution by a data processing apparatus.

The terms quantum information and quantum data refer to information or data that is carried by, held or stored in quantum systems, where the smallest non-trivial system is a qubit, i.e., a system that defines the unit of quantum information. It is understood that the term “qubit” encompasses all quantum systems that may be suitably approximated as a two-level system in the corresponding context. Such quantum systems may include multi-level systems, e.g., with two or more levels. By way of example, such systems can include atoms, electrons, photons, ions or superconducting qubits. In many implementations the computational basis states are identified with the ground and first excited states, however it is understood that other setups where the computational states are identified with higher level excited states are possible.

The term “data processing apparatus” refers to digital and/or quantum data processing hardware and encompasses all kinds of apparatus, devices, and machines for processing digital and/or quantum data, including by way of example a programmable digital processor, a programmable quantum processor, a digital computer, a quantum computer, multiple digital and quantum processors or computers, and combinations thereof. The apparatus can also be, or further include, special purpose logic circuitry, e.g., an FPGA (field programmable gate array), an ASIC (application-specific integrated circuit), or a quantum simulator, i.e., a quantum data processing apparatus that is designed to simulate or produce information about a specific quantum system. In particular, a quantum simulator is a special purpose quantum computer that does not have the capability to perform universal quantum computation. The apparatus can optionally include, in addition to hardware, code that creates an execution environment for digital and/or quantum computer programs, e.g., code that constitutes processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of them.

A digital computer program, which may also be referred to or described as a program, software, a software application, a module, a software module, a script, or code, can be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a digital computing environment. A quantum computer program, which may also be referred to or described as a program, software, a software application, a module, a software module, a script, or code, can be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and translated into a suitable quantum programming language, or can be written in a quantum programming language, e.g., QCL or Quipper.

A digital and/or quantum computer program may, but need not, correspond to a file in a file system. A program can be stored in a portion of a file that holds other programs or data, e.g., one or more scripts stored in a markup language document, in a single file dedicated to the program in question, or in multiple coordinated files, e.g., files that store one or more modules, sub-programs, or portions of code. A digital and/or quantum computer program can be deployed to be executed on one digital or one quantum computer or on multiple digital and/or quantum computers that are located at one site or distributed across multiple sites and interconnected by a digital and/or quantum data communication network. A quantum data communication network is understood to be a network that may transmit quantum data using quantum systems, e.g. qubits. Generally, a digital data communication network cannot transmit quantum data, however a quantum data communication network may transmit both quantum data and digital data.

The processes and logic flows described in this specification can be performed by one or more programmable digital and/or quantum computers, operating with one or more digital and/or quantum processors, as appropriate, executing one or more digital and/or quantum computer programs to perform functions by operating on input digital and quantum data and generating output. The processes and logic flows can also be performed by, and apparatus can also be implemented as, special purpose logic circuitry, e.g., an FPGA or an ASIC, or a quantum simulator, or by a combination of special purpose logic circuitry or quantum simulators and one or more programmed digital and/or quantum computers.

For a system of one or more digital and/or quantum computers to be “configured to” perform particular operations or actions means that the system has installed on it software, firmware, hardware, or a combination of them that in operation cause the system to perform the operations or actions. For one or more digital and/or quantum computer programs to be configured to perform particular operations or actions means that the one or more programs include instructions that, when executed by digital and/or quantum data processing apparatus, cause the apparatus to perform the operations or actions. A quantum computer may receive instructions from a digital computer that, when executed by the quantum computing apparatus, cause the apparatus to perform the operations or actions.

Digital and/or quantum computers suitable for the execution of a digital and/or quantum computer program can be based on general or special purpose digital and/or quantum processors or both, or any other kind of central digital and/or quantum processing unit. Generally, a central digital and/or quantum processing unit will receive instructions and digital and/or quantum data from a read-only memory, a random access memory, or quantum systems suitable for transmitting quantum data, e.g. photons, or combinations thereof.

The essential elements of a digital and/or quantum computer are a central processing unit for performing or executing instructions and one or more memory devices for storing instructions and digital and/or quantum data. The central processing unit and the memory can be supplemented by, or incorporated in, special purpose logic circuitry or quantum simulators. Generally, a digital and/or quantum computer will also include, or be operatively coupled to receive digital and/or quantum data from or transfer digital and/or quantum data to, or both, one or more mass storage devices for storing digital and/or quantum data, e.g., magnetic, magneto-optical disks, optical disks, or quantum systems suitable for storing quantum information. However, a digital and/or quantum computer need not have such devices.

Digital and/or quantum computer-readable media suitable for storing digital and/or quantum computer program instructions and digital and/or quantum data include all forms of non-volatile digital and/or quantum memory, media and memory devices, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks, e.g., internal hard disks or removable disks; magneto-optical disks; CD-ROM and DVD-ROM disks; and quantum systems, e.g., trapped atoms or electrons. It is understood that quantum memories are devices that can store quantum data for a long time with high fidelity and efficiency, e.g., light-matter interfaces where light is used for transmission and matter for storing and preserving the quantum features of quantum data such as superposition or quantum coherence.

Control of the various systems described in this specification, or portions of them, can be implemented in a digital and/or quantum computer program product that includes instructions that are stored on one or more non-transitory machine-readable storage media, and that are executable on one or more digital and/or quantum processing devices. The systems described in this specification, or portions of them, can each be implemented as an apparatus, method, or system that may include one or more digital and/or quantum processing devices and memory to store executable instructions to perform the operations described in this specification.

While this specification contains many specific implementation details, these should not be construed as limitations on the scope of what may be claimed, but rather as descriptions of features that may be specific to particular implementations. Certain features that are described in this specification in the context of separate implementations can also be implemented in combination in a single implementation. Conversely, various features that are described in the context of a single implementation can also be implemented in multiple implementations separately or in any suitable sub-combination. Moreover, although features may be described above as acting in certain combinations and even initially claimed as such, one or more features from a claimed combination can in some cases be excised from the combination, and the claimed combination may be directed to a sub-combination or variation of a sub-combination.

Similarly, while operations are depicted in the drawings in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. In certain circumstances, multitasking and parallel processing may be advantageous. Moreover, the separation of various system modules and components in the implementations described above should not be understood as requiring such separation in all implementations, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.

Particular implementations of the subject matter have been described. Other implementations are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve desirable results. As one example, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some cases, multitasking and parallel processing may be advantageous. 

What is claimed is:
 1. A method for performing a modular exponentiation operation using a target quantum register of qubits and a source quantum register of qubits, the method comprising: for each index in a first set of indices, determining a first plurality of address values, comprising extracting multiple source register values; for each index in a second set of indices, determining a second plurality of address values, comprising extracting multiple target register values; for each index in a third set of indices and for each index in a fourth set of indices, determining a table entry by multiplying i) the index in the third set of indices, ii) the index in the fourth set of indices, and iii) 2 to the power of the index in the second set of indices, and applying a modulus operation; adjusting a modular addition register using table entries corresponding to the first plurality of address values and the second plurality of address values; for each index in a fifth set of indices, determining a third plurality of address values, comprising extracting multiple values of the adjusted modular addition register; for each index in a sixth set of indices, for each index in a seventh set of indices, determining a table entry by multiplying i) the index in the sixth set of indices, ii) the index in the seventh set of indices, and iii) 2 to the power of the index in the fifth set of indices, and applying a modulus operation; and adjusting the target quantum register using table entries corresponding to the first plurality of address values and the third plurality of address values.
 2. The method of claim 1, wherein the first set of indices comprises index values between zero and a first maximum index value that is a function of the source quantum register, wherein the index values are stepped by a first predetermined window size.
 3. The method of claim 1, wherein the second set of indices comprises index values between zero and a second maximum index value that is a function of the target register, wherein the index values are stepped by a second predetermined window size.
 4. The method of claim 2, wherein the third set of indices comprises index values between 1 and a third maximum value that is based on the first predetermined window size.
 5. The method of claim 3, wherein the fourth set of indices comprises index values between 0 and a fourth maximum value that is a function of the target quantum register and the second predetermined window size.
 6. The method of claim 3, wherein the fifth set of indices comprises index values between zero and a fifth maximum index value that is a function of the target register, wherein the index values are stepped by the second predetermined window size.
 7. The method of claim 3, wherein the sixth set of indices comprises index values between 1 and a sixth value that is based on the second predetermined window size.
 8. The method of claim 3, wherein the seventh set of indices comprises index values between 0 and a seventh maximum value that is a function of the modular addition register and the second predetermined window size.
 9. The method of claim 1, wherein determining the first plurality of address values comprises extracting source register values corresponding to indices between i) the index in the first set of indices, and ii) the index in the first set of indices plus the first predetermined window size.
 10. The method of claim 1, wherein determining the second plurality of address values comprises extracting target register values corresponding to indices between i) the index in the second set of indices, and ii) the index in the second set of indices plus the second predetermined window size.
 11. The method of claim 1, wherein determining the third plurality of address values comprises extracting values of the adjusted modular addition register corresponding to indices between i) the index in the fifth set of indices, and ii) the index in the fifth set of indices plus the second predetermined window size.
 12. The method of claim 1, wherein the first maximum index value that is a function of the source quantum register is equal to the length of the source quantum register.
 13. The method of claim 1, wherein the second maximum index value that is a function of the target register is equal to the length of the target quantum register.
 14. The method of claim 1, wherein the third maximum value that is based on the first predetermined window size comprises k^(2i+w1) where k represents a scalar for the modular exponentiation operation, i represents the index in the first set of indices, and w₁ represents the first predetermined window size.
 15. The method of claim 1, wherein the fourth maximum value that is a function of the target quantum register and the second predetermined window size comprises 2 to the power of the second window size.
 16. The method of claim 1, wherein the fifth maximum index value that is a function of the target register is equal to the length of the target quantum register.
 17. The method of claim 1, wherein the seventh maximum value that is a function of the target quantum register and the second predetermined window size comprises 2 to the power of the second window size.
 18. The method of claim 1, wherein the modular exponentiation operation performs x∗= k^(e) (mod N), where x represents a variable storing a first value in the target quantum register, e represents a corresponding variable storing a second value in the source quantum register, k represents a classical constant scalar value for the modular exponentiation operation, and N represent a classical constant modulo for the modular exponentiation operation.
 19. The method of claim 18, wherein the first value comprises a classical integer or a superposition of classical integers and wherein the second value comprises a classical integer or a superposition of classical integers.
 20. The method of claim 8, wherein the first predetermined window size and the second window size are equal.
 21. The method of claim 8, wherein the first predetermined window size and second predetermined window size are equal to In n/2, where n represents a number of logical qubits in the target quantum register.
 22. An apparatus comprising: one or more classical computing processors; and quantum computing hardware in data communication with the one or more classical processors, wherein the apparatus is configured to perform operations for performing a modular exponentiation operation using a target quantum register of qubits and a source quantum register of qubits, the operations comprising: for each index in a first set of indices, determining a first plurality of address values, comprising extracting multiple source register values; for each index in a second set of indices, determining a second plurality of address values, comprising extracting multiple target register values; for each index in a third set of indices and for each index in a fourth set of indices, determining a table entry by multiplying i) the index in the third set of indices, ii) the index in the fourth set of indices, and iii) 2 to the power of the index in the second set of indices, and applying a modulus operation; adjusting a modular addition register using table entries corresponding to the first plurality of address values and the second plurality of address values; for each index in a fifth set of indices, determining a third plurality of address values, comprising extracting multiple values of the adjusted modular addition register; for each index in a sixth set of indices, for each index in a seventh set of indices, determining a table entry by multiplying i) the index in the sixth set of indices, ii) the index in the seventh set of indices, and iii) 2 to the power of the index in the fifth set of indices, and applying a modulus operation; and adjusting the target quantum register using table entries corresponding to the first plurality of address values and the third plurality of address values. 